package code07_面向对象;

public class Test07_方法重载 {
	public static void main(String[] args) {
		// 调用时会根据传递的参数的不同，自动调用相应的重载方法
		System.out.println(Calculator.sum(3, 6));
		System.out.println(Calculator.sum(4, 2, 7));
		System.out.println(Calculator.sum(2.5, 6.2));
		System.out.println(Calculator.sum(6, 2.2));
		System.out.println(Calculator.sum(4.5, 3));
	}
}

/*
 * 计算器类
 */
class Calculator {

	/*
	 * 方法重载
	 */
	public static int sum(int num1, int num2) {
		System.out.println("int,int......");
		return num1 + num2;
	}

	public static int sum(int num1, int num2, int num3) {
		System.out.println("int,int,int......");
		return num1 + num2 + num3;
	}

	public static double sum(double num1, double num2) {
		System.out.println("double,double......");
		return num1 + num2;
	}

	public static double sum(int num1, double num2) {
		System.out.println("int,double......");
		return num1 + num2;
	}
	
	public static double sum(double num1, int num2) {
		System.out.println("double,int......");
		return num1 + num2;
	}
	
//	public static double sum(int a, int b) {
//		System.out.println("int,int......");
//		return a + b;
//	}
}
